import {
  createRouter,
  createWebHistory
} from 'vue-router'
import HomeView from '../views/HomeView.vue'

const router = createRouter({
  history: createWebHistory(
    import.meta.env.BASE_URL),
  routes: [{
      path: '/index',
      name: 'index',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.

      component: () => import('../views/index.vue'),
      redirect: '/',
      children: [{
          path: '/',
          name: 'home',
          component: HomeView
        },
        {
          path: '/about',
          name: 'about',
          // route level code-splitting
          // this generates a separate chunk (About.[hash].js) for this route
          // which is lazy-loaded when the route is visited.
          component: () => import('../views/AboutView.vue')
        },
        {
          path: '/wdk',
          name: 'wdk',
          // route level code-splitting
          // this generates a separate chunk (About.[hash].js) for this route
          // which is lazy-loaded when the route is visited.
          component: () => import('../views/wdk.vue')
        },
        {
          path: '/mw',
          name: 'mw',
          // route level code-splitting
          // this generates a separate chunk (About.[hash].js) for this route
          // which is lazy-loaded when the route is visited.
          component: () => import('../views/mw.vue')
        },
        {
          path: '/wd',
          name: 'wd',
          // route level code-splitting
          // this generates a separate chunk (About.[hash].js) for this route
          // which is lazy-loaded when the route is visited.
          component: () => import('../views/wd.vue')
        }, {
          path: '/gj',
          name: 'gj',
          // route level code-splitting
          // this generates a separate chunk (About.[hash].js) for this route
          // which is lazy-loaded when the route is visited.
          component: () => import('../views/gj.vue')
        }
      ]

    },
    {
      path: '/gkk',
      name: 'gkk',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/gkk.vue')
    },
    {
      path: '/xq',
      name: 'xq',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/xq.vue')
    },
    {
      path: '/msxq',
      name: 'msxq',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/msxq.vue')
    },
    {
      path: '/qbls',
      name: 'qbls',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/qbls.vue')
    },
    {
      path: '/login',
      name: 'login',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/login.vue')
    },
    {
      path: '/dzgl',
      name: 'dzgl',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/dzgl.vue')
    },
    {
      path: '/dhkc',
      name: 'dhkc',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/dhkc.vue')
    },
    {
      path: '/wddd',
      name: 'wddd',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/wddd.vue')
    },
    {
      path: '/xzdz',
      name: 'xzdz',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/xzdz.vue')
    },
    {
      path: '/qrdd',
      name: 'qrdd',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/qrdd.vue')
    },
    {
      path: '/wdsc',
      name: 'wdsc',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/wdsc.vue')
    },
    {
      path: '/wdhy',
      name: 'wdhy',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/wdhy.vue')
    },
    {
      path: '/wdyhj',
      name: 'wdyhj',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/wdyhj.vue')
    },
    {
      path: '/wdxx',
      name: 'wdxx',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/wdxx.vue')
    },
    {
      path: '/xxtz',
      name: 'xxtz',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/xxtz.vue')
    },
    {
      path: '/wtfk',
      name: 'wtfk',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/wtfk.vue')
    }
  ]
})

router.beforeEach((to, form) => {

  if (localStorage.getItem('ttt')) {
    // console.log(1);
    return true;
  } else {
    console.log(2);
    // return 'home'
    console.log(to);
    to.fullPath = '/'
  }
})
export default router